//
//  StatementViewController.h
//  Thinkape-iOS
//
//  Created by 刚刚买的电脑 on 15/11/18.
//  Copyright © 2015年 TIXA. All rights reserved.
//

#import "ParentsViewController.h"
#import <JavaScriptCore/JavaScriptCore.h>


@protocol JavaScriptObjcDelegate <JSExport>

- (void)callWithString:(NSString *)string;

//JS调用OC，然后在OC中通过调用JS方法来传值给JS
- (void)jsCallObjcAndObjcCallJsWithString:(NSString *)str;

//js调用这个方法获得UID;
- (NSString *)getUserId2Html;
- (NSString *)sendDeptId2Html;
//关闭VC：
- (void)closeReport;

@end

@protocol YLJsObjcModelCloseVCDelegate ;

@interface YLJsObjcModel : NSObject<JavaScriptObjcDelegate>

@property (nonatomic,weak)id <YLJsObjcModelCloseVCDelegate> delegate;

@property (weak, nonatomic) UIWebView *webView0;
@property (nonatomic,weak) JSContext *context0;
@property (nonatomic,copy) NSString *uid;
@property (nonatomic,copy) NSString *idepid;
@end
@protocol YLJsObjcModelCloseVCDelegate <NSObject>

- (void)closeVC;

@end

@implementation YLJsObjcModel

- (void)callWithString:(NSString *)string
{
      NSLog(@"Js调用了OC的方法，参数为：%@", string);
    
}
- (void)jsCallObjcAndObjcCallJsWithString:(NSString *)str
{
    JSValue *jsValue = self.context0[@"getUserId2Html()"];
    
    [jsValue callWithArguments:@[@"100"]];
    
}

-(NSString *)getUserId2Html
{
    return self.uid;
}

//部门id：
- (NSString *)sendDeptId2Html
{
    return self.idepid;
    
}
- (void)closeReport
{
    if (self.delegate) {
        [self.delegate closeVC];
    }
}
@end

@interface StatementViewController : UIViewController <YLJsObjcModelCloseVCDelegate>

@property (weak, nonatomic) IBOutlet UIWebView *webView;
@property (nonatomic,weak)JSContext *context;

         
@end
